#pragma once

#include <vector>

#include "observer/Observer.hpp"

class Subject
{
protected:
    std::vector<Observer_ptr> m_observers;

public:
    Subject() = default;
    virtual ~Subject() = default;

    // 添加监听者
    void AddObserver(Observer_ptr observer) {
        m_observers.push_back(observer);
        observer->SetSubject(*this);
    }

    virtual void Notify(const std::string &state) const {
        for (auto observer : m_observers) {
            observer->Update(state);
        }
    }
};
